package pl.planuz;

import java.io.IOException;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

public class PlanUZActivity extends Activity implements OnClickListener{
	private database dh; 
	static boolean wyko;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.dh = new database(this,null,null,null);
        if(dh.isTableExists("wk", true)==true){
        	if(wyko==false){
        	Intent i2 = new Intent(this, PlanActivity.class);
			startActivity(i2);
        	}else{
        		setContentView(R.layout.main);
                View button1Click = findViewById(R.id.button1);
        		button1Click.setOnClickListener(this);
        	}
        }else{
        setContentView(R.layout.main);
        View button1Click = findViewById(R.id.button1);
		button1Click.setOnClickListener(this);
        }
    }
   
   public static void wykonaj(boolean wyk){
	   wyko= wyk;
   }
   public boolean wyk(){
	   return wyko;
   }
	public void onClick(View v) {
		Parser p=new Parser();
		try {
			List<String> list = p.pobierzKierunki();
			for(int i=0;i<list.size();i=i+3){
				this.dh.insert(list.get(i), list.get(i+1), list.get(i+2));
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		switch(v.getId()){

		case R.id.button1:
			Intent i = new Intent(this, CheckActivity.class);
			startActivity(i);
			break;
		
	}
}
}
